﻿<%@ WebHandler Language="C#" Class="BaseHandler" %>

using System;
using System.Web;
using System.Reflection;
using System.Data;

public class BaseHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        if (context.Request["method"] != null)
        {
            lock (this)
            {
                MethodInfo mi = this.GetType().GetMethod(context.Request["method"]);
                mi.Invoke(this, new object[] { context });
            }
        }
    }

    public void GetYear(HttpContext context)
    {
        context.Response.Write(ToCn(DateTime.Now.ToString("yyyy年")));
    }

    public void GetRally(HttpContext context)
    {
        DataTable dt = DBHelper.GetDataTable("select ID,Name,StartTime,EndTime from temple_rally where Year=" + DateTime.Now.Year + " order by StartTime desc");
        context.Response.Write(JsonHelper.ToJson(dt));
    }

    private static string[] cn = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
    private string ToCn(string Date)
    {
        for (int i = 0; i < cn.Length; i++)
        {
            Date = Date.Replace(i.ToString(), cn[i]);
        }
        return Date;
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}